/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package robotlion.view;

import java.awt.Point;
import robotlion.controller.InfoRobot;
import robotlion.model.EEtat;



/**
 *
 * @author test
 */
public class RobotVue implements Observateur{

    
    public String nom;
    public int vitesse;
    public Point position;
    public Point destination;
    public int nivAccessibilite;
    public EEtat etat;
    public int algorithme;
    
    ListeRobotTableModel tableModel;
    FenetreRobotLion terrain;
    
    public RobotVue(ListeRobotTableModel tableModel, FenetreRobotLion terrain) {
        this.tableModel = tableModel;
        this.terrain = terrain;
    }
    
    @Override
    public void updateObs(Object info) {
        if(info.getClass() == InfoRobot.class)
        {
            InfoRobot inforecup = (InfoRobot)info;
            nom = inforecup.nom;
            vitesse = inforecup.vitesse;
            position = inforecup.position;
            destination = inforecup.destination;
            nivAccessibilite = inforecup.nivAccessibilite;
            etat = inforecup.etat;
            algorithme = inforecup.algorithme;

            tableModel.update(nom, etat, position);
            terrain.updateRobot(nom, position.x, position.y);
        }
        else if(info.getClass() == String.class)
        {
            // signal delete observer
            String nomRobot = (String)info; 
            tableModel.deleteRobotByName(nomRobot);
            terrain.removeRobot(nomRobot);
        }
    }
}
